C++ is a general-purpose programming language created by Bjarne Stroustrup as an extension of the C programming language. It supports object-oriented, procedural, and generic programming paradigms.
The major differences include:
A class is a blueprint for creating objects, providing initial values for member variables and implementations of methods. An object is an instance of a class.
Inheritance is a feature of OOP that allows a class (derived class) to inherit properties and behaviors from another class (base class). It promotes code reuse and hierarchical classification..
Answer: Polymorphism allows methods to do different things based on the object it is acting upon. It can be achieved through function overloading, operator overloading, and method overriding (via virtual functions).
Virtual functions are member functions in a base class that can be overridden in derived classes. They enable runtime polymorphism and dynamic binding.
A constructor is a special member function that is automatically called when an object is created. It is used to initialize objects.
A destructor is a special member function that is automatically called when an object is destroyed. It is used to release resources allocated by the object.
A shallow copy copies all member field values. A deep copy duplicates everything an object references, ensuring that copied objects have their own separate copies of dynamically allocated memory. .
Pointers are variables that store the memory address of another variable. They are used for dynamic memory allocation, arrays, and function arguments.
The this pointer is an implicit pointer available inside non-static member functions of a class, which points to the object that invoked the function
"One example of my creativity occurred when I was tasked with [mention a specific project or challenge]. We were facing [describe the problem or objective], and it required a fresh approach to achieve our goals.
Templates allow functions and classes to operate with generic types, enabling code reuse for any data type. They are the basis for the Standard Template Library (STL).
STL is a collection of template classes and functions for common data structures and algorithms, such as vectors, lists, queues, and sorting/searching algorithms
new is an operator in C++ that allocates memory and calls the constructor, whereas malloc is a C library function that allocates memory but does not call the constructor.
The access specifiers in C++ are public, private, and protected. They define the access level of class members.
Operator overloading allows you to redefine the way operators work for user-defined types. For example, you can overload the + operator to add two objects of a class.
Function overloading allows multiple functions to have the same name with different parameters (different type and/or number of parameters).
A namespace is a declarative region that provides a scope to identifiers (names of types, functions, variables, etc.). It is used to organize code and prevent name collisions.
RAII is a programming idiom in C++ where resource allocation is tied to object lifetime. Resources are acquired and released by the constructor and destructor, respectively.
The const keyword is used to define constants and to prevent variables from being modified. It can also be used with pointers, function parameters, and member functions to enforce immutability.